﻿using System;
using System.Collections.Generic;
using System.Text;
using UnionnetClient.Model;
using System.Windows.Forms;

namespace UnionnetClient
{
	class UnconfigStateWithUI : UnconfigState
	{
		public UnconfigStateWithUI(StateMachine stateMachine)
			: base(stateMachine)
		{
		}

		public void SetMainForm(MainForm mainForm)
		{
			this.mainForm = mainForm;
		}

		public override void  Login()
		{
			base.Login();
			if (!AppEnvironment.Settings.IsAccoutCorrect) //账户未设置
			{
				if (DialogResult.Yes == MessageBox.Show("初次登陆，需要进行设置。是否继续？",
					"提示 - 聚友登陆客户端", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
				{
					Controller.Configure(new SettingsForm());
				}
			}
			else //登陆源没有准备好
			{
				base.GetLoginSourceCompleted += delegate(object _sender, EventArgs _e)
				{
					AppEnvironment.CurrentState.Login(); //此时状态已经切换至UnloginState
				};
			}
		}

		public override void Exit()
		{
			base.Exit();
			Application.Exit();
		}
	
		private MainForm mainForm;
	}
}
